﻿using System;

namespace SBCache
{
    /// <summary>
    /// Represents generic cache.
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// Puts an item into the cache with a cache key to reference its location.
        /// </summary>
        /// <param name="key">The cache key used to reference the item.</param>
        /// <param name="item">The item to be inserted into the cache.</param>
        void Put(string key, object item);

        /// <summary>
        /// Puts an item into the cache with a cache key to reference its location.
        /// </summary>
        /// <param name="key">The cache key used to reference the item.</param>
        /// <param name="item">The item to be inserted into the cache.</param>
        /// <param name="absoluteExpiration">Cache absolute expiration.</param>
        void Put(string key, object item, DateTime absoluteExpiration);

        /// <summary>
        /// Puts an item into the cache with a cache key to reference its location.
        /// </summary>
        /// <param name="key">The cache key used to reference the item.</param>
        /// <param name="item">The item to be inserted into the cache.</param>
        /// <param name="cacheDependency">Cache dependency.</param>
        /// <param name="slidingExpiration">Cache sliding expiration.</param>
        void Put(string key, object item, string cacheDependency, TimeSpan slidingExpiration);

        /// <summary>
        /// Puts an item into the cache with a cache key to reference its location.
        /// </summary>
        /// <param name="key">The cache key used to reference the item.</param>
        /// <param name="item">The item to be inserted into the cache.</param>
        /// <param name="cacheDependency">Cache dependency.</param>
        /// <param name="slidingExpiration">Cache sliding expiration.</param>
        /// <param name="absoluteExpiration">Cache absolute expiration.</param>
        void Put(string key, object item, string cacheDependency, TimeSpan slidingExpiration, DateTime absoluteExpiration);

        /// <summary>
        /// Gets the specified item from the cache.
        /// </summary>
        /// <param name="key">The cache key.</param>
        /// <returns>The retrieved cache item, or null if the key is not found.</returns>
        object Get(string key);

        /// <summary>
        /// Invalidates the specified item with the provided key.
        /// </summary>
        /// <param name="key">The cache key.</param>
        void Invalidate(string key);

        /// <summary>
        /// Clears the cache.
        /// </summary>
        void Clear();
    }
}
